//
// Created by kriko on 2021/7/2.
//

#ifndef CSAPP_SBUF_H
#define CSAPP_SBUF_H

#include "csapp.h"

struct sbuf_t {
    int *buf;
    int n;
    int front;
    int rear;
    sem_t mutex;
    sem_t slots;
    sem_t items;
};

typedef sbuf_t* sbuf_t_ptr;

void sbuf_init(sbuf_t_ptr sp, int n);

void sbuf_deinit(sbuf_t_ptr sp);

void sbuf_insert(sbuf_t_ptr sp, int item);

int sbuf_remove(sbuf_t_ptr sp);
#endif //CSAPP_SBUF_H
